package com.beiding.service;

import com.beiding.pojo.order.Evaluation;
import com.beiding.pojo.room.Room;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@Service
@FeignClient(name = "room")
public interface RoomStorageService {

    @GetMapping("/room/feign/get")
    Room get(@RequestParam("id") String id);

    //带有feign的url将不对外暴露
    @PostMapping("/room/feign/evaluate")
    void evaluate(@RequestBody Evaluation evaluate);


    //占用房源
    @PostMapping("/room/feign/occupy")
    void occupy(@RequestParam("id") String id,@RequestParam("theUser") String theUser);


    /*
        用于调用该方法是在异步在本地线程中执行的,而本地线程中并不具备请求服务时必要的的请求头
        从而出现404的异常
     */

    //释放对房源占用
    @PostMapping(value = "/room/feign/release", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    void release(@RequestParam("id") String id);


}
